package com.mxpio.erp.common.oa.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.mxpio.erp.common.jpa.model.Order;
import com.mxpioframework.filestorage.entity.MxpioFileInfo;
import com.mxpioframework.security.annotation.Dict;
import com.mxpioframework.security.entity.User;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.Date;
import java.util.List;


@Data
@EqualsAndHashCode(callSuper=false)
@Entity
@Table(name = "MB_ERP_REIMBURSE_INVOICE_")
@Schema(description="财务报销发票")
public class ReimburseInvoice extends Order {


    @Column(name = "OA_BIZ_NO_")
    @Schema(description = "报销单编号")
    private String oaBizNo;


    @Column(name = "INVOICE_NO_")
    @Schema(description = "发票号")
    private String invoiceNo;

    @Column(name = "INVOICE_TYPE_")
    @Dict(dicCode = "ERP_SALES_INVOICE_KIND")
    @Schema(description = "发票类型")
    private String invoiceType;

    @Column(name = "BILLING_DATE_")
    @Schema(description = "开票日期")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date billingDate;

    @Column(name = "BIZ_MAN_")
    @Schema(description = "业务员")
    @Dict(dicCode = "username", dicEntity = User.class, dicText = "nickname")
    private String bizMan;

    @Column(name = "CURRENCY_")
    @Schema(description = "币种")
    @Dict(dicCode = "ERP_COMMON_CURRENCY")
    private String currency;

    @Column(name = "BIZ_TYPE_")
    @Schema(description = "业务类型")
    private String bizType;

    @Column(name = "BIZ_PARTNER_")
    @Schema(description = "业务伙伴")
    private String bizPartner;

    @Column(name = "PN_CODE_")
    @Schema(description = "客户编号")
    private String pnCode;

    @Column(name = "PN_NAME_")
    @Schema(description = "客户名称")
    private String pnName;

    @Column(name = "PN_ABBR_")
    @Schema(description = "公司简称")
    private String pnAbbr;

    @Column(name = "PAYMENT_TERMS_")
    @Schema(description = "付款条件")
    private String paymentTerms;

    @Column(name = "MEMO_")
    @Schema(description = "备注")
    private String memo;

    @Schema(description = "纸质发票附件")
    @Column(name = "PAPER_FILE_", columnDefinition = "TEXT")
    @Dict(dicCode = "fileNo", dicEntity = MxpioFileInfo.class, dicText = "fileName")
    private String paperFile;

    @Column(name = "APPLICANTS_")
    @Schema(description = "申请单位")
    @Dict(dicCode = "MB_ERP_OA_REIMBURSEMENT_APPLICANTS")
    private String applicants;

    @Column(name = "APPLICANTS_ABBR_")
    @Schema(description = "申请单位(缩写)")
    private String applicantsAbbr;

    //财务报销发票明细行
    @Transient
    private List<ReimburseInvoiceLine> reimburseInvoiceLines;
    @Override
    public String initTypeCode() {
        return "IV2";
    }
}
